package com.spring.study.bean.definition;

import com.spring.study.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BeanInstantinationDemo {

    public static void main(String[] args) {
        BeanFactory beanFactory = new
                ClassPathXmlApplicationContext("classpath:/META-INF/bean-instantiation-context.xml");
        //静态方法
        User user = beanFactory.getBean("user-by-static-method", User.class);
        User userByInstanceMethod = beanFactory.getBean("user-by-instance-method", User.class);
        User userFactoryBean = beanFactory.getBean("user-factory-bean",User.class);

        System.out.println(user);
        System.out.println(userByInstanceMethod);
        System.out.println(userFactoryBean);
        System.out.println(user == userByInstanceMethod);
        System.out.println(user == userFactoryBean);
    }
}
